
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>编写样式 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="../how-to-use/QRLine.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    基本介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../how-to-use/">
            
                <a href="../how-to-use/">
            
                    
                    使用方法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../how-to-use/QRNormal.html">
            
                <a href="../how-to-use/QRNormal.html">
            
                    
                    QRNormal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../how-to-use/QRRandRect.html">
            
                <a href="../how-to-use/QRRandRect.html">
            
                    
                    QRRandRect
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../how-to-use/QRDsj.html">
            
                <a href="../how-to-use/QRDsj.html">
            
                    
                    QRDsj
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../how-to-use/QR25D.html">
            
                <a href="../how-to-use/QR25D.html">
            
                    
                    QR25D
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../how-to-use/QRImage.html">
            
                <a href="../how-to-use/QRImage.html">
            
                    
                    QRImage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../how-to-use/QRResImage.html">
            
                <a href="../how-to-use/QRResImage.html">
            
                    
                    QRResImage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../how-to-use/QRBubble.html">
            
                <a href="../how-to-use/QRBubble.html">
            
                    
                    QRBubble
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../how-to-use/QRFunc.html">
            
                <a href="../how-to-use/QRFunc.html">
            
                    
                    QRFunc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../how-to-use/QRLine.html">
            
                <a href="../how-to-use/QRLine.html">
            
                    
                    QRLine
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    编写样式
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >编写样式</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7F16;&#x5199;&#x6837;&#x5F0F;">&#x7F16;&#x5199;&#x6837;&#x5F0F;</h1>
<p>react-qrbtf &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x57FA;&#x672C;&#x7684;API&#x6765;&#x5E2E;&#x52A9;&#x5F00;&#x53D1;&#x8005;&#x5728;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x4E0A;&#x5236;&#x4F5C;&#x5C5E;&#x4E8E;&#x81EA;&#x5DF1;&#x7684;&#x6837;&#x5F0F;&#x751F;&#x6210;&#x89C4;&#x5219;</p>
<p>&#x672C;&#x6587;&#x4EE5;&#x5236;&#x4F5C;&#x4E00;&#x4E2A;&#x4EE5;&#x5706;&#x5F62;&#x4E3A;&#x4E3B;&#x9898;&#x7684;&#x6700;&#x7B80;&#x5355;&#x7684;&#x4E8C;&#x7EF4;&#x7801;&#x6837;&#x5F0F;&#x6765;&#x5E2E;&#x52A9;&#x8BFB;&#x8005;&#x4E86;&#x89E3;&#x7F16;&#x5199;&#x4E8C;&#x7EF4;&#x7801;&#x6837;&#x5F0F;&#x7684;&#x57FA;&#x672C;&#x6D41;&#x7A0B;</p>
<h3 id="&#x6837;&#x5F0F;&#x7684;&#x57FA;&#x672C;&#x7ED3;&#x6784;">&#x6837;&#x5F0F;&#x7684;&#x57FA;&#x672C;&#x7ED3;&#x6784;</h3>
<p>React&#x63A8;&#x8350;&#x4F7F;&#x7528;&#x51FD;&#x6570;&#x7EC4;&#x4EF6;(Function Component)&#xFF0C;&#x56E0;&#x6B64;&#x4EE5;&#x4E0B;&#x6559;&#x7A0B;&#x4EE5;&#x7F16;&#x5199;&#x51FD;&#x6570;&#x7EC4;&#x4EF6;&#x4E3A;&#x4F8B;</p>
<p>&#x9996;&#x5148;&#x65B0;&#x5EFA;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7684;&#x7EC4;&#x4EF6;&#x6587;&#x4EF6; <code>QRRound.js</code></p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;react&apos;</span>;
<span class="hljs-keyword">import</span> {defaultViewBox, RendererWrapper} <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;react-qrbtf&quot;</span>;

<span class="hljs-keyword">const</span> QRRound = (props) =&gt; {
    <span class="hljs-keyword">const</span> { qrcode, className, styles } = props;
    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">svg</span> <span class="hljs-attr">className</span>=<span class="hljs-string">{className}</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{styles.svg}</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;100%&quot;</span> <span class="hljs-attr">height</span>=<span class="hljs-string">&quot;100%&quot;</span> <span class="hljs-attr">viewBox</span>=<span class="hljs-string">{defaultViewBox(qrcode)}</span> <span class="hljs-attr">fill</span>=<span class="hljs-string">&quot;white&quot;</span>
             <span class="hljs-attr">xmlns</span>=<span class="hljs-string">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="hljs-attr">xmlnsXlink</span>=<span class="hljs-string">&quot;http://www.w3.org/1999/xlink&quot;</span>&gt;</span>
            {listPoints(props)}
        <span class="hljs-tag">&lt;/<span class="hljs-name">svg</span>&gt;</span></span>
    );
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">listPoints</span>(<span class="hljs-params">{ qrcode, size, dataColor }</span>) </span>{
    <span class="hljs-keyword">return</span> [];
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> RendererWrapper(QRRound);
</code></pre>
<p>&#x5982;&#x4F60;&#x6240;&#x89C1;&#xFF0C;react-qrbtf&#x7684;&#x4E8C;&#x7EF4;&#x7801;&#x6837;&#x5F0F;&#x6700;&#x7EC8;&#x7684;&#x751F;&#x6210;&#x662F;&#x5BF9;<code>&lt;svg&gt;</code>&#x76F8;&#x5173;&#x6807;&#x7B7E;(<code>&lt;rect&gt;</code> <code>&lt;round&gt;</code> &#x7B49;)&#x7EC4;&#x5408;</p>
<p>&#x5982;&#x679C;&#x4F60;&#x8FD8;&#x4E0D;&#x592A;&#x4E86;&#x89E3;svg&#x76F8;&#x5173;&#x6807;&#x7B7E;&#x7684;&#x57FA;&#x672C;&#x53C2;&#x6570;&#x548C;&#x4F7F;&#x7528;&#xFF0C;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x6587;&#x6863;&#xFF1A;<a href="https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/svg" target="_blank">https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/svg</a></p>
<p>&#x4E0B;&#x9762;&#x662F;&#x5BF9;&#x4EE3;&#x7801;&#x4E2D;&#x51FA;&#x73B0;&#x7684;&#x4E00;&#x4E9B;API&#x7684;&#x89E3;&#x91CA;</p>
<p><code>defaultViewBox</code>: react-qrbtf&#x9ED8;&#x8BA4;&#x5BF9;&#x6240;&#x6709;&#x751F;&#x6210;&#x7684;&#x4E8C;&#x7EF4;&#x7801;&#x7684;&#x56DB;&#x8FB9;&#x6709;&#x7559;&#x767D;&#xFF0C;&#x5982;&#x679C;&#x60A8;&#x4E0D;&#x559C;&#x6B22;&#xFF0C;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x8C03;&#x6574;</p>
<p><code>RendererWrapper</code>: react-qrbtf&#x63D0;&#x4F9B;&#x7684;&#x9AD8;&#x9636;&#x7EC4;&#x4EF6;(HOC)&#xFF0C;&#x5C01;&#x88C5;&#x4E86;&#x6839;&#x636E;<code>value</code>&#x8BA1;&#x7B97;<code>qrcode</code>&#xFF0C;<code>styles</code>&#x4E0E;<code>defaultCSS</code>&#x7684;&#x5408;&#x5E76;&#x7B49;&#x7B49;</p>
<p><code>listPoints</code>: &#x5B9E;&#x9645;&#x4E0A;&#x53EA;&#x662F;&#x4E3A;&#x4E86;&#x4EE3;&#x7801;&#x7684;&#x7ED3;&#x6784;&#x6027;&#x800C;&#x72EC;&#x7ACB;&#x8BBE;&#x7F6E;&#x51FA;&#x6765;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4ED6;&#x6839;&#x636E;&#x4F20;&#x5165;&#x7684;<code>props</code>&#x6765;&#x8BA1;&#x7B97;&#x5E76;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5305;&#x542B;<code>&lt;svg&gt;</code>&#x76F8;&#x5173;&#x6807;&#x7B7E;&#x7684;&#x6570;&#x7EC4;&#x7528;&#x4E8E;&#x663E;&#x793A;</p>
<h3 id="&#x6837;&#x5F0F;&#x53C2;&#x6570;&#x7684;&#x9ED8;&#x8BA4;&#x503C;">&#x6837;&#x5F0F;&#x53C2;&#x6570;&#x7684;&#x9ED8;&#x8BA4;&#x503C;</h3>
<p>&#x7531;&#x7B2C;&#x4E00;&#x6B65;<code>listPoints</code>&#x7684;&#x53C2;&#x6570;&#x5217;&#x8868;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#xFF0C;&#x9664;&#x4E86;&#x6BCF;&#x4E00;&#x4E2A;&#x6837;&#x5F0F;&#x751F;&#x6210;&#x90FD;&#x9700;&#x8981;&#x7684;<code>qrcode</code>&#x70B9;&#x9635;&#x4FE1;&#x606F;&#x5916;&#xFF0C;&#x8FD9;&#x4E2A;&#x6837;&#x5F0F;&#x8FD8;&#x9700;&#x8981;<code>size</code>&#x548C;<code>dataColor</code>&#x4E24;&#x4E2A;&#x652F;&#x6301;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x540C;&#x65F6;&#xFF0C;&#x7531;&#x4E8E;&#x8BBE;&#x7F6E;&#x4E86;<code>style={styles.svg}</code>&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x5BF9;&#x6837;&#x5F0F;&#x7EC4;&#x4EF6;&#x9ED8;&#x8BA4;&#x7684;css&#x6837;&#x5F0F;&#x8FDB;&#x884C;&#x8C03;&#x6574;</p>
<pre><code class="lang-js">QRRound.defaultCSS = {
    svg: {
        width: <span class="hljs-string">&apos;500px&apos;</span>
    }
}

QRRound.defaultProps = {
    styles: {},
    size: <span class="hljs-number">100</span>,
    dataColor: <span class="hljs-string">&apos;#20ceb7&apos;</span>
}
</code></pre>
<p>&#x5982;&#x4E0A;&#xFF0C;&#x6211;&#x4EEC;&#x8BBE;&#x7F6E;svg&#x9ED8;&#x8BA4;&#x7684;&#x5BBD;&#x5EA6;&#x4E3A;500px&#xFF0C;&#x8BBE;&#x7F6E;&#x4FE1;&#x606F;&#x70B9;&#x7684;&#x5927;&#x5C0F;(<code>size</code>)&#x4E3A;100(&#x53D6;&#x51B3;&#x4E8E;&#x4F60;&#x4E0B;&#x9762;&#x5982;&#x4F55;&#x4F7F;&#x7528;)&#xFF0C;&#x9ED8;&#x8BA4;&#x4FE1;&#x606F;&#x70B9;&#x7684;&#x989C;&#x8272;&#x4E3A;<code>#20ceb7</code></p>
<h3 id="&#x751F;&#x6210;&#x4E8C;&#x7EF4;&#x7801;&#x6837;&#x5F0F;">&#x751F;&#x6210;&#x4E8C;&#x7EF4;&#x7801;&#x6837;&#x5F0F;</h3>
<p>&#x6700;&#x540E;&#x7684;&#x91CD;&#x5934;&#x620F;&#x5C31;&#x662F;<code>listPoints</code>&#x7684;&#x7F16;&#x5199;&#x4E86;</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> {defaultViewBox, getTypeTable, QRPointType, RendererWrapper} <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;react-qrbtf&quot;</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">listPoints</span>(<span class="hljs-params">{ qrcode, size, dataColor }</span>) </span>{
    size = size / <span class="hljs-number">100</span>;

    <span class="hljs-keyword">let</span> id = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">const</span> nCount = qrcode.getModuleCount();
    <span class="hljs-keyword">const</span> typeTable = getTypeTable(qrcode);
    <span class="hljs-keyword">const</span> pointList = [];

    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> x = <span class="hljs-number">0</span>; x &lt; nCount; x++) {
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> y = <span class="hljs-number">0</span>; y &lt; nCount; y++) {
            <span class="hljs-keyword">if</span> (qrcode.isDark(x, y) == <span class="hljs-literal">false</span>) <span class="hljs-keyword">continue</span>;

            <span class="hljs-keyword">if</span> (typeTable[x][y] == QRPointType.POS_CENTER) {
                <span class="hljs-comment">// &#x5728;3&#x4E2A;&#x5B9A;&#x4F4D;&#x70B9;&#x7684;&#x4E2D;&#x5FC3;&#x751F;&#x6210;&#x540C;&#x5FC3;&#x7684;&#x5706;&#x548C;&#x73AF;</span>
                pointList.push(&lt;circle key={id++} fill=&quot;#000000&quot; cx={x + 0.5} cy={y + 0.5} r={1.5} /&gt;)
                pointList.push(&lt;circle key={id++} fill=&quot;none&quot; strokeWidth=&quot;1&quot; stroke=&quot;#000000&quot;  cx={x + 0.5} cy={y + 0.5} r={3} /&gt;)
            } else if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER || typeTable[x][y] == QRPointType.TIMING) {
                // &#x7279;&#x6B8A;&#x70B9;&#x4F7F;&#x7528;&#x9ED1;&#x8272;&#x7684;&#x5706;&#x70B9;
                pointList.push(&lt;circle opacity={1.0} r={size / 2} key={id++} fill=&quot;#000000&quot; cx={x + 0.5} cy={y + 0.5}/&gt;)
            } else if (typeTable[x][y] != QRPointType.POS_OTHER) {
                // &#x5176;&#x4ED6;&#x7684;&#x4FE1;&#x606F;&#x70B9;&#x4F7F;&#x7528;dataColor&#x8272;&#x7684;&#x5706;&#x70B9;
                pointList.push(&lt;circle opacity={1.0} r={size / 2} key={id++} fill={dataColor} cx={x + 0.5} cy={y + 0.5}/&gt;)
            }
        }
    }

    return pointList;
}
</code></pre>
<p>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x5C06; <code>size = size / 100</code>&#x8FD9;&#x8BF4;&#x660E;&#x6211;&#x4EEC;&#x8D4B;&#x4E88;<code>size</code>&#x7684;&#x610F;&#x601D;&#x662F;&#x76F8;&#x5BF9;&#x4E8E;<code>1</code>&#x7684;&#x767E;&#x5206;&#x6BD4;&#xFF08;&#x5F53;&#x7136;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#xFF09;</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> id = <span class="hljs-number">0</span>;
</code></pre>
<p>React &#x8981;&#x6C42;&#x6211;&#x4EEC;&#x5728;&#x5FAA;&#x73AF;&#x751F;&#x6210;&#x7EC4;&#x4EF6;&#x5143;&#x7D20;&#x7684;&#x65F6;&#x5019;&#x4E3A;&#x6BCF;&#x4E2A;&#x6807;&#x7B7E;&#x63D0;&#x4F9B;<code>key</code>&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x7B80;&#x5355;&#x7684;&#x7528;&#x6570;&#x5B57;<code>id</code>&#x9012;&#x589E;&#x4F5C;&#x4E3A;<code>key</code>&#x4E86;</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> nCount = qrcode.getModuleCount();
</code></pre>
<p>&#x8FD9;&#x91CC;&#x5F15;&#x7528;<a href="https:/zh.wikipedia.org/wiki/QR&#x78BC;" target="_blank">&#x7EF4;&#x57FA;&#x767E;&#x79D1;&#x4E0A;&#x5BF9;&#x4E8C;&#x7EF4;&#x7801;&#x7248;&#x672C;&#x7684;&#x89E3;&#x91CA;</a></p>
<blockquote>
<p>QR&#x7801;&#x4E00;&#x5171;&#x63D0;&#x4F9B;40&#x79CD;&#x4E0D;&#x540C;&#x7248;&#x672C;&#x5B58;&#x50A8;&#x5BC6;&#x5EA6;&#x7684;&#x7ED3;&#x6784;&#xFF0C;&#x5BF9;&#x5E94;&#x6307;&#x793A;&#x56FE;&#x7684;&#x201C;&#x7248;&#x672C;&#x4FE1;&#x606F;&#x201D;&#xFF0C;&#x7248;&#x672C;1&#x4E3A;21&#xD7;21&#x6A21;&#x5757;&#xFF08;&#x6A21;&#x5757;&#x4E3A;QR&#x7801;&#x4E2D;&#x7684;&#x6700;&#x5C0F;&#x5355;&#x5143;&#xFF09;&#xFF0C;&#x6BCF;&#x589E;&#x52A0;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#xFF0C;&#x957F;&#x5BBD;&#x5404;&#x589E;&#x52A0;4&#x4E2A;&#x6A21;&#x5757;&#xFF0C;&#x6700;&#x5927;&#x7684;&#x7248;&#x672C;40&#x4E3A;177&#xD7;177&#x6A21;&#x5757;&#x3002;</p>
</blockquote>
<p>&#x6240;&#x4EE5;&#x8FD9;&#x91CC;<code>nCount</code>&#x5C31;&#x662F;&#x8BA1;&#x7B97;&#x51FA;&#x6765;&#x7684;&#x4E8C;&#x7EF4;&#x7801;&#x7684;&#x6A21;&#x5757;&#x5927;&#x5C0F;</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> typeTable = getTypeTable(qrcode);
</code></pre>
<p><code>getTypeTable</code>&#x5BF9;&#x4E8C;&#x7EF4;&#x7801;&#x8FDB;&#x884C;&#x9010;&#x70B9;&#x5206;&#x7C7B;&#xFF0C;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x8BB0;&#x5F55;&#x4E86;&#x6BCF;&#x4E00;&#x70B9;&#x7C7B;&#x578B;&#x7684;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#xFF0C;&#x5177;&#x4F53;&#x7684;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x4E0B;&#x56FE;&#xFF08;&#x4E4B;&#x540E;&#x7684;&#x4EE3;&#x7801;&#x9700;&#x8981;&#x6839;&#x636E;&#x8FD9;&#x4E2A;&#x7C7B;&#x578B;&#x751F;&#x6210;&#x6807;&#x7B7E;&#xFF09;</p>
<p><img src="../pictures/800px-QR_Code_Structure_Example_3.png" alt="800px-QR_Code_Structure_Example_3.png"></p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> pointList = [];
</code></pre>
<p>&#x6700;&#x540E;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x7A7A;&#x7684;&#x6570;&#x7EC4;&#x5B58;&#x50A8;&#x751F;&#x6210;&#x7ED3;&#x679C;</p>
<pre><code class="lang-js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> x = <span class="hljs-number">0</span>; x &lt; nCount; x++) {
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> y = <span class="hljs-number">0</span>; y &lt; nCount; y++) {
        <span class="hljs-keyword">if</span> (qrcode.isDark(x, y) == <span class="hljs-literal">false</span>) <span class="hljs-keyword">continue</span>;

        <span class="hljs-keyword">if</span> (typeTable[x][y] == QRPointType.POS_CENTER) {
            <span class="hljs-comment">// &#x5728;3&#x4E2A;&#x5B9A;&#x4F4D;&#x70B9;&#x7684;&#x4E2D;&#x5FC3;&#x751F;&#x6210;&#x540C;&#x5FC3;&#x7684;&#x5706;&#x548C;&#x73AF;</span>
            pointList.push(&lt;circle key={id++} fill=&quot;#000000&quot; cx={x + 0.5} cy={y + 0.5} r={1.5} /&gt;)
            pointList.push(&lt;circle key={id++} fill=&quot;none&quot; strokeWidth=&quot;1&quot; stroke=&quot;#000000&quot;  cx={x + 0.5} cy={y + 0.5} r={3}/&gt;)
        } else if (typeTable[x][y] == QRPointType.ALIGN_CENTER || 
                   typeTable[x][y] == QRPointType.ALIGN_OTHER || 
                   typeTable[x][y] == QRPointType.TIMING) {
            // &#x7279;&#x6B8A;&#x70B9;&#x4F7F;&#x7528;&#x9ED1;&#x8272;&#x7684;&#x5706;&#x70B9;
            pointList.push(&lt;circle opacity={1.0} r={size / 2} key={id++} fill=&quot;#000000&quot; cx={x + 0.5} cy={y + 0.5}/&gt;)
        } else if (typeTable[x][y] != QRPointType.POS_OTHER) {
            // &#x5176;&#x4ED6;&#x7684;&#x4FE1;&#x606F;&#x70B9;&#x4F7F;&#x7528;dataColor&#x8272;&#x7684;&#x5706;&#x70B9;
            pointList.push(&lt;circle opacity={1.0} r={size / 2} key={id++} fill={dataColor} cx={x + 0.5} cy={y + 0.5}/&gt;)
        }
    }
}
</code></pre>
<p>&#x904D;&#x5386;&#x70B9;&#x9635;&#x7684;&#x6BCF;&#x4E00;&#x70B9;&#xFF0C;&#x6839;&#x636E;&#x8FD9;&#x4E00;&#x70B9;&#x7684;&#x7C7B;&#x578B;&#x751F;&#x6210;&#x4E0D;&#x540C;&#x7684;svg&#x56FE;&#x50CF;</p>
<p><code>QRPointType</code>&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x4E0D;&#x540C;&#x70B9;&#x7C7B;&#x578B;&#x7684;&#x679A;&#x4E3E;&#x7C7B;&#x578B;(Enum)&#xFF0C;&#x7C7B;&#x578B;&#x540D;&#x79F0;&#x53EF;&#x4EE5;&#x5BF9;&#x5E94;&#x4E0A;&#x56FE; (<code>CENTER</code>&#x540E;&#x7F00;&#x4EE3;&#x8868;&#x4E2D;&#x5FC3;&#xFF0C;<code>OTHER</code>&#x540E;&#x7F00;&#x4EE3;&#x8868;&#x4E2D;&#x5FC3;&#x4EE5;&#x5916;&#x56DB;&#x5468;&#x7684;&#x70B9;)</p>
<p>&#x5728;&#x52A0;&#x5165;JSX&#x6807;&#x7B7E;&#x65F6;&#xFF0C;&#x4F7F;&#x7528;<code>size</code> <code>dataColor</code>&#x7B49;&#x53C2;&#x6570;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;</p>
<p>&#x6700;&#x540E;&#x5C31;&#x80FD;&#x5728;&#x5176;&#x4ED6;&#x7EC4;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;&#x5566;</p>
<pre><code class="lang-js">&lt;QRRound value={<span class="hljs-string">&quot;https://qrbtf.com&quot;</span>} size={<span class="hljs-number">80</span>} dataColor=<span class="hljs-string">&quot;#c95eb7&quot;</span>/&gt;
</code></pre>
<p><img src="../pictures/example.png" alt="example.png"></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../how-to-use/QRLine.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: QRLine">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"编写样式","level":"1.3","depth":1,"previous":{"title":"QRLine","level":"1.2.9","depth":2,"path":"how-to-use/QRLine.md","ref":"how-to-use/QRLine.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"how-to-create/README.md","mtime":"2020-06-28T07:19:36.164Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-05T08:25:41.444Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

